﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ObjectEditor="clr-namespace:ObjectEditor"
                    xmlns:EnumEditor="clr-namespace:EnumEditor;assembly=EnumEditor"
                    xmlns:Validation="clr-namespace:ObjectEditor.Validation"
                    xmlns:Converters="clr-namespace:ObjectEditor.Converters">

    <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="16"/>
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="16" Width="16" Margin="0">
                                <Ellipse Margin="0" x:Name="circle" HorizontalAlignment="Center" StrokeThickness="0.5" Stroke="DarkGray" VerticalAlignment="Center" Height="16" Width="16"/>
                                <Path x:Name="arrow" Data="M 0,-1 L 0,1 M -1,0 L 1,0" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="1" VerticalAlignment="Center" Height="10" Stretch="Fill" Width="10"/>
                            </Grid>
                            <ContentPresenter x:Name="ExpanderContent" Grid.Column="0" HorizontalAlignment="Left" Margin="0,0,5,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="M -1,0 L 1,0"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}" Value="">
                            <Setter Property="Visibility" TargetName="ExpanderContent" Value="Collapsed"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="19"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid>
                                <Grid.LayoutTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <TransformCollection>
                                                <RotateTransform Angle="180"/>
                                            </TransformCollection>
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Grid.LayoutTransform>
                                <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="19" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/>
                                <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/>
                            </Grid>
                            <ContentPresenter Grid.Column="1" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderLeftHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="19"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid>
                                <Grid.LayoutTransform>
                                    <TransformGroup>
                                        <TransformGroup.Children>
                                            <TransformCollection>
                                                <RotateTransform Angle="90"/>
                                            </TransformCollection>
                                        </TransformGroup.Children>
                                    </TransformGroup>
                                </Grid.LayoutTransform>
                                <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="19" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/>
                                <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/>
                            </Grid>
                            <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderHeaderFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle Margin="0" SnapsToDevicePixels="true" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="16"/>
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="16" Width="16" Margin="0">
                                <Ellipse Margin="0" x:Name="circle" HorizontalAlignment="Center" StrokeThickness="0.5" Stroke="DarkGray" VerticalAlignment="Center" Height="16" Width="16"/>
                                <Path x:Name="arrow" Data="M 0,-1 L 0,1 M -1,0 L 1,0" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="1" VerticalAlignment="Center" Height="10" Stretch="Fill" Width="10"/>
                            </Grid>
                            <ContentPresenter x:Name="ExpanderContent" Grid.Column="0" HorizontalAlignment="Left" Margin="0,0,5,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="M -1,0 L 1,0"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}" Value="">
                            <Setter Property="Visibility" TargetName="ExpanderContent" Value="Collapsed"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Expander}" x:Key="ExpanderStyle">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="true">
                        <DockPanel>
                            <ToggleButton x:Name="HeaderSite" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" Style="{StaticResource ExpanderDownHeaderStyle}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <ContentPresenter x:Name="ExpandSite" DockPanel.Dock="Bottom" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Right">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
                            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Up">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
                            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Left">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
                            <Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderLeftHeaderStyle}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <Style x:Key="LabelStyle">
        <Setter Property="TextBlock.VerticalAlignment" Value="Center"/>
        <Setter Property="TextBlock.FontWeight" Value="Bold"/>
        <Setter Property="TextBlock.Margin" Value="{Binding DataContext.DescriptionMargin, ElementName=ObjectControl}"/>
    </Style>

    <Style x:Key="ElementStyle">
        <Setter Property="Control.VerticalAlignment" Value="Center"/>
        <Setter Property="Control.Margin" Value="{Binding DataContext.ChildMargin, ElementName=ObjectControl}"/>
    </Style>

    <Style x:Key="GridStyle" TargetType="{x:Type Grid}" BasedOn="{ObjectEditor:StaticApplicationResource {x:Type Grid}}">
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Margin" Value="{Binding DataContext.ChildMargin, ElementName=ObjectControl}"/>
    </Style>



    <ControlTemplate x:Key="BaseTemplate" TargetType="{x:Type ContentControl}">
        <StackPanel Orientation="{Binding DataContext.ChildOrientation, ElementName=ObjectControl}" Visibility="{Binding Value, Converter={x:Static Converters:Null.ToCollapsed}}">
            <Grid Margin="{Binding DataContext.DescriptionMargin, ElementName=ObjectControl}"
                  Visibility="{Binding DataContext.IsDescriptionVisible, ElementName=ObjectControl, Converter={x:Static Converters:False.ToCollapsed}}">

                <TextBox Background="Transparent" BorderThickness="0" IsReadOnly="True" TextWrapping="NoWrap"
                         Text="{Binding Mode=OneWay}" FontWeight="Bold" VerticalAlignment="Center"
                         x:Name="DescriptionElement" Margin="-3,-1,0,0" Padding="0" Cursor="{x:Static Cursors.Arrow}"/>
            </Grid>
            <ContentPresenter/>
        </StackPanel>

        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding Info, Converter={x:Static Converters:NotNull.ToTrue}}" Value="False">
                <Setter TargetName="DescriptionElement" Property="Visibility" Value="Collapsed"></Setter>
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Converters:SingleToStringConverter x:Key="SingleToStringConverter"/>
    <Converters:IntToStringConverter x:Key="IntToStringConverter"/>
    <Converters:StringToDoubleConverter x:Key="StringToDoubleConverter"/>
    
    <DataTemplate DataType="{x:Type ObjectEditor:AbstractValue}">
        <ContentControl Content="{Binding}" Template="{StaticResource BaseTemplate}">
            <ContentControl.ContentTemplate>
                <DataTemplate>
                    <Grid Style="{StaticResource GridStyle}">
                        <ContentControl Content="{Binding}" ContentTemplateSelector="{Binding DataContext.TemplateSelector, ElementName=ObjectControl}"/>
                    </Grid>
                </DataTemplate>
            </ContentControl.ContentTemplate>
        </ContentControl>
    </DataTemplate>

    <DataTemplate DataType="{x:Type ObjectEditor:CollectionItem}">
        <ContentControl Content="{Binding}" ContentTemplateSelector="{Binding DataContext.TemplateSelector, ElementName=ObjectControl}"/>
    </DataTemplate>

    <DataTemplate x:Key="Collection">
        <ItemsControl ItemsSource="{Binding Items}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="{Binding DataContext.ChildOrientation, ElementName=ObjectControl}"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentControl Content="{Binding}"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </DataTemplate>

    <DataTemplate x:Key="CollectionReadOnly">
        <ItemsControl ItemsSource="{Binding Items}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="{Binding DataContext.ChildOrientation, ElementName=ObjectControl}"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentControl Content="{Binding}"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </DataTemplate>

    <DataTemplate x:Key="Boolean">
        <CheckBox IsChecked="{Binding Value}">
            <TextBox Background="Transparent" BorderThickness="0" IsReadOnly="True" TextWrapping="NoWrap" Text="{Binding Mode=OneWay}"/>
        </CheckBox>
    </DataTemplate>

    <DataTemplate x:Key="BooleanReadOnly">
        <CheckBox IsChecked="{Binding Value, Mode=OneWay}" IsEnabled="False">
            <TextBox Background="Transparent" BorderThickness="0" IsReadOnly="True" TextWrapping="NoWrap" Text="{Binding Mode=OneWay}"/>
        </CheckBox>
    </DataTemplate>

    <DataTemplate x:Key="Enum">
        <EnumEditor:EnumEditor Value="{Binding Value}"
                               TranslatePrefix="{Binding DataContext.TranslatePrefix, ElementName=ObjectControl}"
                               Templates="{Binding DataContext.Templates, ElementName=ObjectControl}"/>
    </DataTemplate>

    <DataTemplate x:Key="EnumReadOnly">
        <EnumEditor:EnumEditor Value="{Binding Value, Mode=OneWay}"
                               IsReadOnly="True"
                               TranslatePrefix="{Binding DataContext.TranslatePrefix, ElementName=ObjectControl}"
                               Templates="{Binding DataContext.Templates, ElementName=ObjectControl}"/>
    </DataTemplate>

    <DataTemplate x:Key="String">
        <TextBox Text="{ObjectEditor:ValidatorBinding Value, UpdateSourceTrigger=PropertyChanged}"/>
    </DataTemplate>

    <DataTemplate x:Key="StringReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>

    <DataTemplate x:Key="Single">
        <TextBox>
            <TextBox.Text>
                <ObjectEditor:ValidatorBinding Path="Value" Converter="{StaticResource SingleToStringConverter}" UpdateSourceTrigger="PropertyChanged">
                    <ObjectEditor:ValidatorBinding.ValidatorRule>
                        <Validation:DoubleRule/>
                    </ObjectEditor:ValidatorBinding.ValidatorRule>
                </ObjectEditor:ValidatorBinding>
            </TextBox.Text>
        </TextBox>
    </DataTemplate>

    <DataTemplate x:Key="SingleReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>

    <DataTemplate x:Key="Double">
        <TextBox>
            <TextBox.Text>
                <ObjectEditor:ValidatorBinding Path="Value" Converter="{StaticResource StringToDoubleConverter}" ConverterParameter="F2" UpdateSourceTrigger="PropertyChanged">
                    <ObjectEditor:ValidatorBinding.ValidatorRule>
                        <Validation:DoubleRule/>
                    </ObjectEditor:ValidatorBinding.ValidatorRule>
                </ObjectEditor:ValidatorBinding>
            </TextBox.Text>
        </TextBox>
    </DataTemplate>

    <DataTemplate x:Key="DoubleReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>

    <DataTemplate x:Key="Int32">
        <TextBox>
            <TextBox.Text>
                <ObjectEditor:ValidatorBinding Path="Value" Converter="{StaticResource IntToStringConverter}" UpdateSourceTrigger="PropertyChanged">
                    <ObjectEditor:ValidatorBinding.ValidatorRule>
                        <Validation:IntRule/>
                    </ObjectEditor:ValidatorBinding.ValidatorRule>
                </ObjectEditor:ValidatorBinding>
            </TextBox.Text>
        </TextBox>
    </DataTemplate>

    <DataTemplate x:Key="Int32ReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>

    <DataTemplate x:Key="UInt32">
        <TextBox>
            <TextBox.Text>
                <ObjectEditor:ValidatorBinding Path="Value" Converter="{StaticResource IntToStringConverter}" UpdateSourceTrigger="PropertyChanged">
                    <ObjectEditor:ValidatorBinding.ValidatorRule>
                        <Validation:IntRule Min="0"/>
                    </ObjectEditor:ValidatorBinding.ValidatorRule>
                </ObjectEditor:ValidatorBinding>
            </TextBox.Text>
        </TextBox>
    </DataTemplate>

    <DataTemplate x:Key="UInt32ReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>

    <DataTemplate x:Key="Byte">
        <TextBox>
            <TextBox.Text>
                <ObjectEditor:ValidatorBinding Path="Value" Converter="{StaticResource IntToStringConverter}" UpdateSourceTrigger="PropertyChanged">
                    <ObjectEditor:ValidatorBinding.ValidatorRule>
                        <Validation:IntRule Min="0" Max="255"/>
                    </ObjectEditor:ValidatorBinding.ValidatorRule>
                </ObjectEditor:ValidatorBinding>
            </TextBox.Text>
        </TextBox>
    </DataTemplate>

    <DataTemplate x:Key="ByteReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>

    <DataTemplate x:Key="UInt64">
        <TextBox>
            <TextBox.Text>
                <ObjectEditor:ValidatorBinding Path="Value" Converter="{StaticResource IntToStringConverter}" UpdateSourceTrigger="PropertyChanged">
                    <ObjectEditor:ValidatorBinding.ValidatorRule>
                        <Validation:LongRule Min="0"/>
                    </ObjectEditor:ValidatorBinding.ValidatorRule>
                </ObjectEditor:ValidatorBinding>
            </TextBox.Text>
        </TextBox>
    </DataTemplate>

    <DataTemplate x:Key="UInt64ReadOnly">
        <TextBlock Text="{Binding Value}"/>
    </DataTemplate>


    <DataTemplate x:Key="DefaultTemplate">
        <Expander DataContext="{Binding}" Header="{Binding Converter={x:Static Converters:FromObject.ToString}}"
                  FontWeight="Bold" Margin="{Binding DataContext.DescriptionMargin, ElementName=ObjectControl}" x:Name="ContentExpander"
                  Style="{StaticResource ExpanderStyle}">
            <Expander.ContentTemplate>
                <DataTemplate>
                    <ObjectEditor:ObjectEditor Value="{Binding ElementName=ContentExpander, Path=DataContext}"
                                               TranslatePrefix="{Binding DataContext.TranslatePrefix, ElementName=ObjectControl}"
                                               ShowAttributes="{Binding DataContext.ShowAttributes, ElementName=ObjectControl}"
                                               Orientation="{Binding DataContext.Orientation, ElementName=ObjectControl}"
                                               ChildOrientation="{Binding DataContext.ChildOrientation, ElementName=ObjectControl}"
                                               IsDescriptionVisible="{Binding DataContext.IsDescriptionVisible, ElementName=ObjectControl}"
                                               DescriptionMargin="{Binding DataContext.DescriptionMargin, ElementName=ObjectControl}"
                                               ChildMargin="{Binding DataContext.ChildMargin, ElementName=ObjectControl}"
                                               Templates="{Binding DataContext.Templates, ElementName=ObjectControl}"
                                               Style="{StaticResource ElementStyle}" FontWeight="Regular" IsReadOnly="False">
                    </ObjectEditor:ObjectEditor>
                </DataTemplate>
            </Expander.ContentTemplate>
        </Expander>

        <!--<StackPanel Orientation="{Binding DataContext.ChildOrientation, ElementName=ObjectControl}">-->

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding DataContext.ChildOrientation, ElementName=ObjectControl}" Value="Horizontal">
                <Setter TargetName="ContentExpander" Property="ExpandDirection" Value="Right"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Info, Converter={x:Static Converters:NotNull.ToTrue}}" Value="False">
                <Setter TargetName="ContentExpander" Property="FontWeight" Value="Regular"/>
                <Setter TargetName="ContentExpander" Property="Margin" Value="{Binding DataContext.ChildMargin, ElementName=ObjectControl}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>